package fun.qu_an.minecraft.voicechatplugin;

import com.mojang.brigadier.CommandDispatcher;
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.text.Text;

import static net.minecraft.server.command.CommandManager.literal;

public class MultiFuncChatCommand {
	public static void register(CommandDispatcher<ServerCommandSource> dispatcher) {
		dispatcher.register(literal("vcbroadcast")
			.then(literal("teamspeak")
				.requires(source -> source.hasPermissionLevel(3))
				.executes(context -> {
					boolean b = MultiFuncChatConfig.get().isTeamSpeak();
					MultiFuncChatConfig.get().setTeamSpeak(!b);
					MultiFuncChatConfig.save();
					context.getSource().sendFeedback(Text.of("teamspeak 已设为 " + !b), false);
					return 1;
				}))
			.then(literal("enable")
				.requires(source -> source.hasPermissionLevel(3))
				.executes(context -> {
					boolean b = MultiFuncChatConfig.get().isEnable();
					MultiFuncChatConfig.get().setEnable(!b);
					MultiFuncChatConfig.save();
					context.getSource().sendFeedback(Text.of("enable 已设为 " + !b), false);
					return 1;
				}))
			.then(literal("reload")
				.requires(source -> source.hasPermissionLevel(3))
				.executes(context -> {
					MultiFuncChatConfig.load();
					context.getSource().sendFeedback(Text.of("已重载配置文件！"), false);
					return 1;
				})));
	}
}
